package cn.itcast.order.web;

import cn.itcast.order.config.InformationConfig;
import cn.itcast.order.config.TestConfiguration;
import cn.itcast.order.pojo.Order;
import cn.itcast.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("order")
@RefreshScope
public class OrderController {

   @Autowired
   private OrderService orderService;
   @Autowired
   private InformationConfig informationConfig;

   @Autowired
   private TestConfiguration testConfiguration;

    @GetMapping("{orderId}")
    public Order queryOrderByUserId(@PathVariable("orderId") Long orderId,
                                    @RequestHeader("niganma") String niganma) {
        System.out.println(niganma);
        // 根据id查询订单并返回
        return orderService.queryOrderById(orderId);
    }

    @GetMapping("/test")
    public String queryInfo(){
        String str = informationConfig.getXxxx();
        String nnnn = testConfiguration.getNnnn();
        System.out.println(nnnn);
        System.out.println(str);
        return str + nnnn;
    }

}